from sqlalchemy import create_engine

from sqlalchemy.orm import DeclarativeBase, scoped_session, sessionmaker
from sqlalchemy.pool import QueuePool

from app.configs.config import SQLALCHEMY_DATABASE_URI, SQLALCHEMY_ENGINE_OPTIONS

# 创建数据库引擎
engine = create_engine(SQLALCHEMY_DATABASE_URI,
                       poolclass=QueuePool,
                       **SQLALCHEMY_ENGINE_OPTIONS
                       )

# 创建基类


class Base(DeclarativeBase):
    pass


db_session = scoped_session(sessionmaker(
    autocommit=False, autoflush=False, bind=engine))  # 创建作用域级别的会话工厂

